Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class PHONGTAMBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As PHONGTAMDto)
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDPHONGTAM As System.Int32)
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.xoa(IDPHONGTAM)
 End Sub
 Public Sub sua(ByVal Dto As PHONGTAMDto)
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHONGTAM As PHONGTAMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHONGTAM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaIDPHONG( ByVal IDPHONG as System.Int32, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaIDPHONG(IDPHONG,IDPHONGTAM)
 End Sub 
 Public Sub suaIDLOPHOC( ByVal IDLOPHOC as System.Int32, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaIDLOPHOC(IDLOPHOC,IDPHONGTAM)
 End Sub 
 Public Sub suaTUNGAY( ByVal TUNGAY as System.DateTime, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaTUNGAY(TUNGAY,IDPHONGTAM)
 End Sub 
 Public Sub suaDENNGAY( ByVal DENNGAY as System.DateTime, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaDENNGAY(DENNGAY,IDPHONGTAM)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDPHONGTAM)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDPHONGTAM As System.Int32 )
 Dim dao As New PHONGTAMDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDPHONGTAM)
 End Sub 
 Public Function LayBangTable( ByVal IDPHONGTAM As System.Int32) As DataTable
 Dim Dao As New PHONGTAMDao(IDPHONGTAM,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDPHONGTAM As System.Int32) As IList
 Dim Dao As New PHONGTAMDao(IDPHONGTAM,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoPHONGTAM As PHONGTAMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoPHONGTAM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDPHONGTAM (ByVal IDPHONGTAM As System.Int32) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDPHONGTAM(IDPHONGTAM)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHONGTAM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDPHONGTAM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHONGTAM (ByVal IDPHONGTAM As System.Int32) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoIDPHONGTAM(IDPHONGTAM)
 End sub
 Public Function LayBangTableTheoIDPHONG (ByVal IDPHONG As System.Int32) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDPHONG(IDPHONG)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDPHONG (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDPHONG(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDPHONG (ByVal IDPHONG As System.Int32) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoIDPHONG(IDPHONG)
 End sub
 Public Function LayBangTableTheoIDLOPHOC (ByVal IDLOPHOC As System.Int32) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDLOPHOC(IDLOPHOC)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDLOPHOC (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoIDLOPHOC(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDLOPHOC (ByVal IDLOPHOC As System.Int32) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoIDLOPHOC(IDLOPHOC)
 End sub
 Public Function LayBangTableTheoTUNGAY (ByVal TUNGAY As System.DateTime) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoTUNGAY(TUNGAY)
 Return Dao
 End Function
 Public Function LayBangTableTheoTUNGAY(ByVal TUNGAY1 As System.DateTime,ByVal TUNGAY2 As System.DateTime ) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoTUNGAY(TUNGAY1 ,TUNGAY2)
 Return Dao
 End Function
 Public Function LayBangTableTheoTUNGAY (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoTUNGAY(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTUNGAY (ByVal TUNGAY As System.DateTime) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoTUNGAY(TUNGAY)
 End sub
 Public Function LayBangTableTheoDENNGAY (ByVal DENNGAY As System.DateTime) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoDENNGAY(DENNGAY)
 Return Dao
 End Function
 Public Function LayBangTableTheoDENNGAY(ByVal DENNGAY1 As System.DateTime,ByVal DENNGAY2 As System.DateTime ) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoDENNGAY(DENNGAY1 ,DENNGAY2)
 Return Dao
 End Function
 Public Function LayBangTableTheoDENNGAY (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoDENNGAY(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoDENNGAY (ByVal DENNGAY As System.DateTime) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoDENNGAY(DENNGAY)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDPHONGTAM As System.Int32) As PHONGTAMdto
 Dim Dao As New PHONGTAMDao(IDPHONGTAM, ketnoi)
 Dim dto As New PHONGTAMdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDPHONGTAM")) = False Then
 Dto.IDPHONGTAM = Dao.Rows(0)("IDPHONGTAM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.IDPHONGTAM")) = False Then
 Dto.IDPHONGTAM = Dao.Rows(0)("PHONGTAM.IDPHONGTAM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(0)("IDPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(0)("PHONGTAM.IDPHONG")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(0)("IDLOPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(0)("PHONGTAM.IDLOPHOC")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TUNGAY")) = False Then
 Dto.TUNGAY = Dao.Rows(0)("TUNGAY")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.TUNGAY")) = False Then
 Dto.TUNGAY = Dao.Rows(0)("PHONGTAM.TUNGAY")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DENNGAY")) = False Then
 Dto.DENNGAY = Dao.Rows(0)("DENNGAY")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.DENNGAY")) = False Then
 Dto.DENNGAY = Dao.Rows(0)("PHONGTAM.DENNGAY")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("PHONGTAM.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("PHONGTAM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("PHONGTAM.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As PHONGTAMdto
 Dim dto As New PHONGTAMdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDPHONGTAM")) = False Then
 Dto.IDPHONGTAM = Dao.Rows(i)("IDPHONGTAM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.IDPHONGTAM")) = False Then
 Dto.IDPHONGTAM = Dao.Rows(i)("PHONGTAM.IDPHONGTAM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(i)("IDPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.IDPHONG")) = False Then
 Dto.IDPHONG = Dao.Rows(i)("PHONGTAM.IDPHONG")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(i)("IDLOPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.IDLOPHOC")) = False Then
 Dto.IDLOPHOC = Dao.Rows(i)("PHONGTAM.IDLOPHOC")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TUNGAY")) = False Then
 Dto.TUNGAY = Dao.Rows(i)("TUNGAY")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.TUNGAY")) = False Then
 Dto.TUNGAY = Dao.Rows(i)("PHONGTAM.TUNGAY")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DENNGAY")) = False Then
 Dto.DENNGAY = Dao.Rows(i)("DENNGAY")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.DENNGAY")) = False Then
 Dto.DENNGAY = Dao.Rows(i)("PHONGTAM.DENNGAY")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("PHONGTAM.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("PHONGTAM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("PHONGTAM.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As PHONGTAMdto
 Dim dto As New PHONGTAMdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New PHONGTAMDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

